Left Termination of the query pattern balance_in_2(g, a) w.r.t. the given Prolog program could successfully be proven:



Prolog
  ↳ PrologToPiTRSProof

Clauses:

balance(T, TB) :- balance55(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []).
balance55(nil, C, T, T, A, B, A, B, X, X).
balance55(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) :- ','(balance55(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)), balance55(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)).
balance5(nil, C, T, T, A, B, A, B, X, X) :- balance55(nil, C, T, T, A, B, A, B, X, X).
balance5(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) :- balance55(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT).
balance(nil, -(X, X), -(A, B), -(A, B), -(.(','(nil, -(C, C)), T), T)) :- balance5(nil, C, T, T, A, B, A, B, X, X).
balance(tree(L, V, R), -(IH, IT), -(.(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T))), -(HR, TR), -(.(','(nil, -(XX0, XX0)), XX1), NT)) :- balance5(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT).

Queries:

balance(g,a).

We use the technique of [30].Transforming Prolog into the following Term Rewriting System:
Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)
U1(T, TB, balance55_out(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x1)
U1(x1, x2, x3)  =  U1(x3)
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
balance_out(x1, x2)  =  balance_out

Infinitary Constructor Rewriting Termination of PiTRS implies Termination of Prolog



↳ Prolog
  ↳ PrologToPiTRSProof
PiTRS
      ↳ DependencyPairsProof

Pi-finite rewrite system:
The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)
U1(T, TB, balance55_out(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x1)
U1(x1, x2, x3)  =  U1(x3)
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
balance_out(x1, x2)  =  balance_out


Using Dependency Pairs [1,30] we result in the following initial DP problem:
Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
BALANCE_IN(T, TB) → BALANCE55_IN(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → BALANCE55_IN(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))
U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U31(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → BALANCE55_IN(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)
U1(T, TB, balance55_out(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x1)
U1(x1, x2, x3)  =  U1(x3)
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
balance_out(x1, x2)  =  balance_out
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U31(x19)
BALANCE_IN(x1, x2)  =  BALANCE_IN(x1)
BALANCE55_IN(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  BALANCE55_IN(x1)
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U21(x3, x19)
U11(x1, x2, x3)  =  U11(x3)

We have to consider all (P,R,Pi)-chains

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
PiDP
          ↳ DependencyGraphProof

Pi DP problem:
The TRS P consists of the following rules:

BALANCE_IN(T, TB) → U11(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
BALANCE_IN(T, TB) → BALANCE55_IN(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → BALANCE55_IN(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))
U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U31(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → BALANCE55_IN(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)
U1(T, TB, balance55_out(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x1)
U1(x1, x2, x3)  =  U1(x3)
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
balance_out(x1, x2)  =  balance_out
U31(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U31(x19)
BALANCE_IN(x1, x2)  =  BALANCE_IN(x1)
BALANCE55_IN(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  BALANCE55_IN(x1)
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U21(x3, x19)
U11(x1, x2, x3)  =  U11(x3)

We have to consider all (P,R,Pi)-chains
The approximation of the Dependency Graph [30] contains 1 SCC with 3 less nodes.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
PiDP
              ↳ UsableRulesProof

Pi DP problem:
The TRS P consists of the following rules:

U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → BALANCE55_IN(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → BALANCE55_IN(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))

The TRS R consists of the following rules:

balance_in(T, TB) → U1(T, TB, balance55_in(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, []))
balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)
U1(T, TB, balance55_out(T, XX0, XX1, [], .(','(nil, -(XX0, XX0)), XX1), [], .(','(TB, -(I, [])), X), X, I, [])) → balance_out(T, TB)

The argument filtering Pi contains the following mapping:
balance_in(x1, x2)  =  balance_in(x1)
U1(x1, x2, x3)  =  U1(x3)
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
[]  =  []
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
balance_out(x1, x2)  =  balance_out
BALANCE55_IN(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  BALANCE55_IN(x1)
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U21(x3, x19)

We have to consider all (P,R,Pi)-chains
For (infinitary) constructor rewriting [30] we can delete all non-usable rules from R.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
PiDP
                  ↳ PiDPToQDPProof

Pi DP problem:
The TRS P consists of the following rules:

U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → BALANCE55_IN(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → BALANCE55_IN(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))
BALANCE55_IN(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U21(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))

The TRS R consists of the following rules:

balance55_in(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT) → U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1)))
balance55_in(nil, C, T, T, A, B, A, B, X, X) → balance55_out(nil, C, T, T, A, B, A, B, X, X)
U2(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(L, XX0, XX1, .(','(nil, -(XX2, XX2)), XX3), HR1, TR1, H, T, IH, .(V, IT1))) → U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_in(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT))
U3(L, V, R, XX0, XX1, NT, HR, TR, LB, VB, RB, A, D, H, X, T, IH, IT, balance55_out(R, XX2, XX3, NT, HR, TR, HR1, TR1, IT1, IT)) → balance55_out(tree(L, V, R), XX0, XX1, NT, HR, TR, .(','(tree(LB, VB, RB), -(A, D)), H), .(','(LB, -(A, .(VB, X))), .(','(RB, -(X, D)), T)), IH, IT)

The argument filtering Pi contains the following mapping:
balance55_in(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_in(x1)
.(x1, x2)  =  .(x1, x2)
','(x1, x2)  =  ','(x1, x2)
nil  =  nil
-(x1, x2)  =  -(x1, x2)
tree(x1, x2, x3)  =  tree(x1, x2, x3)
U2(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U2(x3, x19)
balance55_out(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  balance55_out
U3(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U3(x19)
BALANCE55_IN(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)  =  BALANCE55_IN(x1)
U21(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19)  =  U21(x3, x19)

We have to consider all (P,R,Pi)-chains
Transforming (infinitary) constructor rewriting Pi-DP problem [30] into ordinary QDP problem [15] by application of Pi.

↳ Prolog
  ↳ PrologToPiTRSProof
    ↳ PiTRS
      ↳ DependencyPairsProof
        ↳ PiDP
          ↳ DependencyGraphProof
            ↳ PiDP
              ↳ UsableRulesProof
                ↳ PiDP
                  ↳ PiDPToQDPProof
QDP
                      ↳ QDPSizeChangeProof

Q DP problem:
The TRS P consists of the following rules:

BALANCE55_IN(tree(L, V, R)) → U21(R, balance55_in(L))
BALANCE55_IN(tree(L, V, R)) → BALANCE55_IN(L)
U21(R, balance55_out) → BALANCE55_IN(R)

The TRS R consists of the following rules:

balance55_in(tree(L, V, R)) → U2(R, balance55_in(L))
balance55_in(nil) → balance55_out
U2(R, balance55_out) → U3(balance55_in(R))
U3(balance55_out) → balance55_out

The set Q consists of the following terms:

balance55_in(x0)
U2(x0, x1)
U3(x0)

We have to consider all (P,Q,R)-chains.
By using the subterm criterion [20] together with the size-change analysis [32] we have proven that there are no infinite chains for this DP problem.

From the DPs we obtained the following set of size-change graphs: